package com.example.home.controller;

import com.example.home.Dao.*;
import com.example.home.Entities.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.ListResourceBundle;

@Controller

public class HomeController {

    @Autowired
    StudentRepository studentRepository;

    @Autowired
    CateRepository cateRepository;

    @Autowired
    CollageRepository collageRepository;

    @Autowired
    CourseRepository courseRepository;

    @Autowired
    MajorsRepository majorsRepository;

    @Autowired
    TeacherRepository teacherRepository;


    @GetMapping("/")
    public String displayHome(Model model) {

        List<Student> student = studentRepository.findAll();
        model.addAttribute("Students", student);


        List<Cate> cates = cateRepository.findAll();
        model.addAttribute("Cate", cates);


        List<Collage> collages = collageRepository.findAll();
        model.addAttribute("collageOr", collages);

        List<Course> courses = courseRepository.findAll();
        model.addAttribute("course", courses);

        List<Majors> majors = majorsRepository.findAll();
        model.addAttribute("Majors", majors);


        List<Teacher> teach = teacherRepository.findAll();
        model.addAttribute("teachOr", teach);

        return "Home/home";

    }
}